// 帮我送、帮我取，通用组件
const app = getApp();
Component({
	/**
	 * 组件的属性列表
	 */
	properties: {
		mType: {
			type: Number,
			value: 0
		}
	},

	/**
	 * 组件的初始数据
	 */
	data: {
		collect: {}, // 收
		take: {} // 取
	},

	lifetimes: {
		attached: function() {
			// this.fnInit();
		},
		ready: function () {
			this.fnInit();
		},
	},

	/**
	 * 组件的方法列表
	 */
	methods: {
		fnInit: function() {
			let type = this.properties.mType;
			// console.log('type', type)
			let address = app.get('__user__address').address;
			let collect = {
				dz: '送到哪里去？',
			}, take = {
				dz: '从哪里取货？',
			};
			switch (type) {
				case 0:
					take['dz'] = address;
					take['dh'] = 1008611;
					break;
				case 1:
					collect['dz'] = address;
					collect['dh'] = 1008611;
					break;
			}
			this.setData({take, collect});
		},
		fnReceive: function() {
			app.go('/pages/receive/receive');
			// triggerEvent 注册事件
			// this.triggerEvent('toReceive', { url: '' }, {});
		},
	}
})
